/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// The base class of graph
	/// </summary>
	[Serializable]
	public abstract class EQGraphic: EQRangeBase
	{
		private float mWidth = 320;
		private float mHeight = 240;
		private int mTop;
		private int mLeft;
		private EQBool mExpandRow = EQBool.Default;
		private EQBool mExpandColumn = EQBool.Default;

		/// <summary>
		/// Set/Get whether expand column width
		/// </summary>
		public bool ExpandColumn
		{
			get
			{
				return EQKit.ToBool(this.mExpandColumn);
			}
			set
			{
				this.mExpandColumn = EQKit.ToEQBool(value);
			}
		}

		/// <summary>
		/// Set/Get whether expand row height
		/// </summary>
		public bool ExpandRow
		{
			get
			{
				return EQKit.ToBool(this.mExpandRow);
			}
			set
			{
				this.mExpandRow = EQKit.ToEQBool(value);
			}
		}

		/// <summary>
		/// Set/Get the height of graph
		/// </summary>
		public float Height
		{
			get
			{
				return this.mHeight;
			}
			set
			{
				this.mHeight = EQKit.CheckMeasure(value);
			}
		}

		/// <summary>
		/// Set/Get the width of graph
		/// </summary>
		public float Width
		{
			get
			{
				return this.mWidth;
			}
			set
			{
				this.mWidth = EQKit.CheckMeasure(value);
			}
		}

		/// <summary>
		/// Set/Get the first row index of left-top corner of the graph
		/// </summary>
		public int Top
		{
			get
			{
				return this.mTop;
			}
			set
			{
				this.mTop = EQKit.CheckPosition(value);
			}
		}

		/// <summary>
		/// Set/Get the first column index of left-top corner of the graph
		/// </summary>
		public int Left
		{
			get
			{
				return this.mLeft;
			}
			set
			{
				this.mLeft = EQKit.CheckPosition(value);
			}
		}

		/// <summary>
		/// After inserted graph, please call the function. This function will expand based on the attributions ExpandColumn/ExpandRow
		/// </summary>
		/// <param name="objWorksheet"></param>
		protected internal override void Output(Excel.Worksheet objWorksheet)
		{
			Excel.Range objRange = null;
			if(this.ExpandRow)
			{
				objRange = (Excel.Range)objWorksheet.get_Range(objWorksheet.Cells[this.Top, 1], objWorksheet.Cells[this.Top, 1]);
				objRange.RowHeight = this.Height;
			}

			if(this.ExpandColumn)
			{
				objRange = (Excel.Range)objWorksheet.get_Range(objWorksheet.Cells[1, this.Left], objWorksheet.Cells[1, this.Left]);
				objRange.ColumnWidth = this.Width;
			}
		}
	}
}